<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //声明变量
        let a;
        let b, c, d;
        let e = 100;
        let f = 521, g = 'zzzzz', h = [];

        //变量不能重复声明
        let star = '罗志祥';
        let star = '小猪';

        //2.块级作用域  全局，函数，eval
        //if else while for里面也是块级作用域
        {
            // let girl = '周杨青';  //let声明的变量只在所在块级范围内使用
            var girl = '周杨青';    //var全局作用域，外部可以使用
        }
        console.log(girl);

        //3.不存在变量提升
        console.log(song);   //var声明：undefined,let声明：报错
        var song = '恋爱达人'
        let song = '恋爱达人'

        //4.不影响作用域链
        {
            let scool = '尚硅谷';
            function fn() {
                console.log(school); //这里能调用到，往上级找
            }
            fn()
        }
    </script>
</body>

</html>